//
//  ProductCustom.m
//  cutter
//
//  Created by mac on 16/1/8.
//  Copyright © 2016年 e360. All rights reserved.
//
#import "ProductCustom.h"


//
@implementation ProductSortPrice
-(void)layoutSubviews{
    UIImage *img = [self imageForState:self.state];
    if (img) {
        [self setTitleEdgeInsets:UIEdgeInsetsMake(0, -img.size.width, 0, img.size.width)];
        [self setImageEdgeInsets:UIEdgeInsetsMake(0, self.titleLabel.bounds.size.width + 4, 0, -self.titleLabel.bounds.size.width - 4)];
    }
    if (self.selected) {
        if (self.sort) {
            [self.imageView setTransform:CGAffineTransformMakeScale(1, 1)];
        }else{
            [self.imageView setTransform:CGAffineTransformMakeScale(1,-1)];
        }
    }
    [super layoutSubviews];
}
@end


//
@implementation ProductMutableButton
-(void)layoutSubviews{
    [super layoutSubviews];
    if (self.selected && self.highlighted) {
        UIImage *img = [self imageForState:UIControlStateDisabled];
        if (img) {
            [self.imageView setImage:img];
        }
    }
}
@end


//
@implementation ProductCustomViewCtrl
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //
    if (self.presentationController) {
        UIView *parent = [[self.navigationController view] superview];
        if (parent) {
            [parent.layer setCornerRadius:6];
        }
    }
}
@end